#include <string>

using namespace std;

class Solution
{
public:
    string replaceSpace(string s)
    {
        int i = 0;
        while (i < s.size())
        {
            if (s[i] == ' ')
            {
                s.replace(i, 1, "%20");
                i += 2;
                continue;
            }
            ++i;
        }
        return s;
    }
};